import exec from '../db/connectMysql'

class remark{
  protected id!:number
  protected content!:string
  protected username!:string
  protected time!:string
  protected realname!:string
  protected dongmanId!:number
  search(){
    let sql = `select remark.id,remark.time,remark.username,remark.realname,remark.content from remark left join dongman on
    dongman.id = remark.dongmanId where dongman.id = ?`
    let arr = [this.dongmanId]
    return exec(sql,arr)
  }
  del(){
    let sql = `delete from remark where id = ?`
    let arr = [this.id]
    return exec(sql,arr)
  }
  add(){
    let sql = `insert into remark(username,time,content,realname,dongmanId) values (?,?,?,?,?)`
    let arr = [this.username,this.time,this.content,this.realname,this.dongmanId]
    return exec(sql,arr)
  }
}
export class searchRemark extends remark{
  constructor(id:number){
    super()
    this.dongmanId = id
  }
} 
export class delRemark extends remark{
  constructor(id:number){
    super()
    this.id = id
  }
}
export class addRemark extends remark{
  constructor(username:string,time:string,content:string,dongmanId:number,realname:string){
    super()
    this.username = username
    this.time = time
    this.content = content
    this.dongmanId = dongmanId
    this.realname = realname
  }
}
